package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Main2Activity extends AppCompatActivity {
    private TextView textView2;
    private Button button2;
    private EditText editText2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        textView2=(TextView) findViewById(R.id.tv_2);
        button2=(Button)findViewById(R.id.btn_2);
        editText2=(EditText)findViewById(R.id.et_2);
        //取出数据
        //1、得到意图
        final Intent intent2_1=getIntent();
        //2、从意图中将数据出来
        final String str2=intent2_1.getStringExtra("aa");
        //3、使用数据
        textView2.setText(str2);
        //发送按钮的功能
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent2_2=new Intent(Main2Activity.this,MainActivity.class);
                intent2_2.putExtra("cc",editText2.getText().toString().trim());
                startActivity(intent2_2);
            }
        });
    }
}
